package com.szholly.pro.watergas_server.water.operationsunit;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.szholly.data.general.RowBase;
import com.szholly.plug.form.excel.utils.StringUtil;
import com.szholly.pro.watergas_server.common.data.DataUtil;
import com.szholly.pro.watergas_server.common.web.BaseController;
import com.szholly.pro.watergas_server.common.web.RequestUnit;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import net.sf.json.JSONObject;

@Controller
@RequestMapping("/OperationsUnit/*")
public class OperationsUnitController extends BaseController {
	 @Autowired 
	 OperationsUnitService operationsUnitService;
	    /**
	     * 获取运营单位数据
	     * @param resq
	     * @param res
	     * @throws Exception
	     */
		@RequestMapping("/getList")
		public void getList(HttpServletRequest resq, HttpServletResponse res) throws Exception{
			Map<String,String> params = queryQueryParams();
			List<RowBase> result=operationsUnitService.getList(params);
			JSONObject json = DataUtil.listToJSONObject(result, null, null);
			outString(json.toString());
		}
		private Map<String,String> queryQueryParams() {
			Map<String,String> params = new HashMap<>();
			String GUID = RequestUnit.getParameter("GUID");
			String WWTP_ID = RequestUnit.getParameter("WWTP_ID");
			if (StringUtil.IsNotNullOrEmpty(GUID)) {
				params.put("GUID", GUID);
			}
			if (StringUtil.IsNotNullOrEmpty(WWTP_ID)) {
				params.put("WWTP_ID", WWTP_ID);
			}
			return params;
		}
}
